'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  // 在执行数据库升级时调用的函数，创建 goods 表
  async up(queryInterface, Sequelize) {
    const { INTEGER, DATE, STRING } = Sequelize;
    await queryInterface.createTable('goods', {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      name: STRING(30),
      img: {
        type: STRING,
        allowNull: false,
        comment: '商品图片',
      },
      describe: {
        type: STRING,
        allowNull: false,
        comment: '商品内容',
      },
      price: INTEGER,
      gain: INTEGER,
      created_at: DATE,
      updated_at: DATE,
    });
  },
  // 在执行数据库降级时调用的函数，删除 users 表
  async down(queryInterface) {
    await queryInterface.dropTable('goods');
  },
};
